<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="/template/template-padrao.xhtml">

	<ui:define name="titulo">Cadastrar Entrada</ui:define>

	<ui:define name="baseCorpo">
	
		<h:form id="itemMenuForm">
		
			<h1 class="titulo-tela">Manter itens de menu</h1>

			<p:panel id="panelItemMenu">
			
				<h1 class="ui-panel-titlebar ui-widget-header ui-corner-all">Dados cadastrais</h1>
			
				<table cellspacing="10">
					<tr>
						<td colspan="2">
							<h:outputLabel for="nome" value="* Nome:" style="font-weight: bold;" />
							<br />
							<p:inputText id="nome" value="#{manterItensMenuBean.itemMenu.nmMenu}" 
								maxlength="150" style="width:200px;" />
			            </td>
					</tr>
					<tr>
						<td width="160px;">
							<h:outputLabel for="urlPasta" value="* Url da pasta:" style="font-weight: bold;" />
							<br />
							<p:inputText id="urlPasta" value="#{manterItensMenuBean.itemMenu.urlPasta}"
								maxlength="200" style="width:350px;" />
			            </td>
			            <td width="160px;">
							<h:outputLabel for="urlInicial" value="* Url da página inícial:" style="font-weight: bold;" />
							<br />
							<p:inputText id="urlInicial" value="#{manterItensMenuBean.itemMenu.urlPaginaInicial}"
								maxlength="250" style="width:350px;" />
			            </td>
					</tr>
				</table>
			</p:panel>
			
			<br />
			<div align="right">
				<p:commandButton id="botaoSalvar" value="Salvar" update="msgSistema, itemMenuForm, listaRegistros" 
					actionListener="#{manterItensMenuBean.salvarItemMenu}" style="margin-left:5px;" />
				<p:commandButton id="botaoLimpar" value="Limpar" update="msgSistema, itemMenuForm" 
					 actionListener="#{manterItensMenuBean.limparCampos}" style="margin-left:5px;" />
			</div>
		
		</h:form>
		
		<h:form id="listaRegistros">
			
			<br />
			<br />
			<p:accordionPanel autoHeight="false" collapsible="true" style="padding:0;">
			<p:tab title="Itens de menu">
			
				<p:dataTable id="listaItensMenu" var="itemMenu" 
					paginator="true" rows="10" paginatorPosition="bottom"
					value="#{manterItensMenuBean.todosItensMenu}"
		            emptyMessage="Nenhum item de menu encontrado">
		            
			        <p:column filterBy="#{itemMenu.nmMenu}" 
			                headerText="Nome" filterMatchMode="contains">
			            <h:outputText value="#{itemMenu.nmMenu}" />
			        </p:column>
			        
			         <p:column filterBy="#{itemMenu.urlPasta}" 
			                headerText="Url da pasta" filterMatchMode="contains">
			            <h:outputText value="#{itemMenu.urlPasta}" />
			        </p:column>
			        
			         <p:column filterBy="#{itemMenu.urlPaginaInicial}" 
			                headerText="Url da página inícial" filterMatchMode="contains">
			            <h:outputText value="#{itemMenu.urlPaginaInicial}" />
			        </p:column>
			
			        <p:column style="width:70px;" headerText="Ações">
			            <p:commandButton update="itemMenuForm" image="ui-icon ui-icon-pencil" immediate="true">
			               <f:setPropertyActionListener value="#{itemMenu}"
			                    target="#{manterItensMenuBean.itemMenu}" />
			            </p:commandButton>
			            <p:commandButton oncomplete="confirmation.show()" image="ui-icon ui-icon-trash" immediate="true">
			               <f:setPropertyActionListener value="#{itemMenu}"
			                    target="#{manterItensMenuBean.itemMenuAux}" />
			            </p:commandButton>
			        </p:column>
			        
			    </p:dataTable>
			    
		    </p:tab>
			</p:accordionPanel>
		    
		</h:form>
		
		<h:form>
		    <p:confirmDialog message="Deseja excluir o item de menu?"
						header="Confirmação" severity="alert" widgetVar="confirmation">
						
				<p:commandButton value="Sim" update="itemMenuForm, msgSistema, listaRegistros" 
							oncomplete="confirmation.hide()" immediate="true"
							actionListener="#{manterItensMenuBean.excluirItemMenu}" />
				<p:commandButton value="Não" onclick="confirmation.hide()" type="button" immediate="true" /> 
						
			</p:confirmDialog>
		</h:form>

	</ui:define>

</ui:composition>
</html>